﻿


$(function () {
    //点击寄件人图标弹窗
    layui.use('layer', function () {
        var layer = layui.layer;
        $(".order_address_list").click(function () {
            console.log(11)
            layer.open({
                title: '寄件人信息',
                type: 1,
                area: ['770px', '480px'],
                skin: 'layui-layer-rim', //加上边框
                content: $("#orderAddressListDiv")
            });

        });
    })

    //点击收件人图标弹窗
    layui.use('layer', function () {
        var layer = layui.layer;
        $(".order_address_recvList").click(function () {
            layer.open({
                title: '收件人信息',
                type: 1,
                area: ['770px', '480px'],
                skin: 'layui-layer-rim', //加上边框
                content: $('#recipientsAddressListDiv')
            });
        });
    })

});


//获取地寄件人址列表信息进行文本赋值
function listCallBack() {
    if ($("input[name='checkbox']:checked").length == 1) {
        var checkboxTdArr = $("input[name='checkbox']:checked").parent().parent().children("td");
        if ($(checkboxTdArr[1]).text() == "寄件人"){
            $("#senderName").val($(checkboxTdArr[2]).text());
            $("#senderMobile").val($(checkboxTdArr[3]).text());
            $("#senderLandlineNumber").val($(checkboxTdArr[4]).text());
            var sendAddress = $(checkboxTdArr[5]).text().slice($(checkboxTdArr[5]).text().indexOf("-")+1);
            var sendFullAddress =  $(checkboxTdArr[5]).text().slice(0,$(checkboxTdArr[5]).text().indexOf("-"))
            $("#sendFullAddress").val(sendFullAddress);
            $("#sendAddress").val(sendAddress);
            layer.close(layer.index);
        }
    }else {
        layer.close(layer.index);
        layer.msg("没有选择寄件人信息")
    }
}

//获取收件人地址列表信息进行文本赋值
function recvListCallBack() {
    if ($("input[name='checkbox']:checked").length == 1) {
        var checkboxTdArr = $("input[name='checkbox']:checked").parent().parent().children("td");
        if ($(checkboxTdArr[1]).text() == "收件人"){
            $("#recipientsName").val($(checkboxTdArr[2]).text());
            $("#recipientsMobile").val($(checkboxTdArr[3]).text());
            $("#recipientsLandlineNumber").val($(checkboxTdArr[4]).text());
            var recipientsAddress = $(checkboxTdArr[5]).text().slice($(checkboxTdArr[5]).text().indexOf("-")+1);
            var recipientsFullAddress =  $(checkboxTdArr[5]).text().slice(0,$(checkboxTdArr[5]).text().indexOf("-"))
            $("#recipientsFullAddress").val(recipientsFullAddress);
            $("#recipientsAddress").val(recipientsAddress);
            layer.close(layer.index);
        }
    }else {
        layer.close(layer.index);
        layer.msg("没有选择寄件人信息")
    }
}